import uiautomator2 as u2

from game import game_几何王国, game_暴走弹头
from zz import zz_log, zz_code, zz_str
import sys

log = zz_log.of()


def main():
    arguments = sys.argv[1:]
    d = u2.connect(zz_code.env('DEVICE_ID'))

    index = 0
    if zz_str.has_any_text(arguments[0]):
        index = int(arguments[0])

    if index == 0:
        game = game_几何王国.Game(d, 20 * 3)
    elif index == 1:
        game = game_暴走弹头.Game(d, True, 10)
    else:
        raise RuntimeError(f'Index {index} out of range')
    game.handle_main()
    game.close_game()


if __name__ == '__main__':
    main()
